package guoanmaker.operator.business.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import guoanmaker.operator.business.model.OperatorActiveChance;

public interface OperatorActiveChanceRepository  extends JpaRepository<OperatorActiveChance, String>, JpaSpecificationExecutor<OperatorActiveChance>{
	@Query("select oac from OperatorActiveChance oac where oac.userId=:userId and oac.activeId=:activeId")
	public OperatorActiveChance  queryActiveChanceByuserId(@Param("userId")String userId,@Param("activeId")String activeId);
	@Transactional
	@Modifying
	@Query("UPDATE OperatorActiveChance set number=number-1  where userId=:userId and activeId=:activeId")
	public int updateActiveChance(@Param("userId")String userId,@Param("activeId")String activeId);
	
}
